<template>
  <div id="app">
    <h1>根组件</h1>
    <input type="text" v-model.number="$store.state.nums" />
    <!-- 1. 通过 props 把 num 传给子组件 -->
    <!-- <add-item v-model.number="num"></add-item> -->
    <add-item />
    <hr />
    <!-- 1. 通过 props 把 num 传给子组件 -->
    <!-- <sub-item v-model.number="num"></sub-item> -->
    <sub-item />
    <div>
      store数据的调用展示
    </div>
    <ul>
      <li>{{ $store.state.test }}</li>
    </ul>
  </div>
</template>

<script>
import AddItem from "@/components/AddItem.vue";
import SubItem from "@/components/SubItem.vue";
export default {
  name: "app",
  data: function() {
    return {
      num: 1
    };
  },
  components: {
    AddItem,
    SubItem
  }
};
</script>
<style>
#app {
  width: 300px;
  margin: 20px auto;
  border: 1px solid #ccc;
  padding: 4px;
}
</style>
